package com.sg.hms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

import com.sg.hms.Model.FoodMenu;
import com.sg.hms.Model.Role;
import com.sg.hms.Service.FoodMenuService;
import com.sg.hms.ServiceImpl.FoodMenuServiceImpl;

/**
 * 
 * @author 张杨
 *
 */
public class FindAllFoodMenuController extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
			doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		PrintWriter pw=resp.getWriter();		
		FoodMenuService fmservice=new FoodMenuServiceImpl();	
		int page=Integer.parseInt(req.getParameter("page"));
		int pageSize=Integer.parseInt(req.getParameter("rows"));
		int start=(page-1)*pageSize;
		JSONObject  foodmenus=fmservice.getFoods(start, pageSize);				
		pw.write(foodmenus.toString());

	}
}
